﻿using System.Runtime.InteropServices;
using OdsServer.Common.DataTransfer;

namespace OdsServer.Common.Packet
{
    [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
    public unsafe struct MultiChannel8DataPacket : IBasePacket
    {
        internal PacketHeader header;
        internal long timespan;

        public const int CHANNEL_COUNT = 8;
        internal MarshalChannelDataChunk values;

        public MultiChannel8DataPacket(long t, ushort[] val)
        {
            this.header.type    = PacketType.MultiChannelDataPacket;
            this.values         = new MarshalChannelDataChunk(val);
            this.timespan       = t;
            this.header.lenght  = sizeof(PacketHeader) 
                    + this.values.GetDataChunkBytes() 
                    + sizeof(float) 
                    + sizeof(int);            
        }

        public ushort[] GetValues()
        {
            return this.values.chunk;
        }

        public long GetTimespan()
        {
            return this.timespan;
        }

        public PacketHeader GetHeader()
        {
            return this.header;
        }
    }
}